<template>
  <div class="user_list">
    <div class="list_cell">
        <img :src="$route.query.figure || 'https://cdn.hbjxqp.happypoker.cn/static/img/avatar.png'" alt="头像">
        <div class="user_text">
            <h4>{{$route.query.nick}}</h4>
            <p>{{$route.query.id}}</p>
        </div>
        <x-button mini class="fix_btn" type="primary" @click.native="submit()">添 加</x-button>
    </div>
  </div>
</template>

<script>
import { XButton} from "vux";
import { setUsers } from "../../../../scripts/utils";
export default {
  data() {
    return {
      clubId: null, //亲友圈id
      userType: "", //白名单或者黑名单
      href: "" //添加后跳转的链接
    };
  },
  components: {
    XButton
  },
  created() {
    this.clubId = this.$route.query.clubId;
    if (this.$route.query.whiteListType == 2) {
      this.userType = "black";
    } else {
      this.userType = "white";
    }
  },
  methods: {
    submit() {
      if (this.clubId == null) {
        let user = [
          {
            figure: this.$route.query.figure,
            id: this.$route.query.id,
            nick: this.$route.query.nick
          }
        ];
        setUsers(this.userType, user);
        if (this.$route.query.whiteListType == 2) {
          this.$router.go(-1);
        } else {
          this.$router.go(-2);
        }
      } else {
        this.apiService.club
          .adduser({
            clubid: this.clubId,
            whitelisttype: this.$route.query.whiteListType,
            playerids: [this.$route.query.id],
            type: 2
          })
          .then(res => {
            if (this.$route.query.whiteListType == 2) {
              this.$router.go(-1);
            } else {
              this.$router.go(-2);
            }
          })
      }
    }
  }
};
</script>

<style scoped>
.fix_btn {
  line-height: 0.7rem;
  padding: 0 0.4rem;
}
.user_list .list_cell {
  padding: 0.25rem;
  margin-top: 0.35rem;
  position: relative;
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
  background: #fff;
}
.user_list .list_cell img {
  margin-right: 0.8em;
  width: 0.9rem;
  height: 0.9rem;
  text-align: center;
}
.user_list .user_text {
  -webkit-box-flex: 1;
  -webkit-flex: 1;
  flex: 1;
}
.user_list .user_text h4 {
  font-size: 0.3rem;
  font-weight: 600;
}
.user_list .user_text p {
  color: rgb(85, 85, 85);
  font-size: 0.26rem;
  margin-top: 0.15rem;
}
</style>


